package cn.kgc.javaweb.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: mosin
 * @version: v1.0  2022/6/22
 * StudentServlet  可以处理所有的根student相关的操作
 */
@WebServlet("/student")
public class StudentServlet extends HttpServlet {


    //   /student?method=add   delete  select  update
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //获取请求参数   req
        String method = req.getParameter("method");

        //根据不同的method  调用不同的处理方法
        switch (method) {
            case "add":
                add(req, resp);
                break;
            case "delete":
               delete(req, resp);
                break;
            case "update":
                update(req, resp);
                break;
            case "select":
                select(req, resp);
                break;
        }

    }

    // 添加
    protected void add(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("student add()");

    }

    // 删除
    protected void delete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("student delete()");

    }

    // 修改
    protected void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("student update()");

    }

    //查询
    protected void select(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        System.out.println("student select()");
    }


}
